<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="<s:url value="/css/a.css"/>" type="text/css" rel="stylesheet" />
<link href="<s:url value="/css/index.css"/>" type="text/css" rel="stylesheet" />
	
<script type="text/javascript"
	src="<c:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-1.7.2.min.js" />"></script>
	
<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>

<style>
　　　
　　　　　a {
	text-decoration: none
}

　　　　　a:hover {
	color: red;
	text-decoration: none
}

a:VISITED {
	color: red;
}
　　


　　　
</style>

<script type="text/javascript">
$(document).ready(function() {
      $("#sub").click(function(){   
      
         var  accountNo = $("#accountNo").val();
         if(accountNo==null || accountNo==""){
            alert("代理商不能为空");
			return false;
         }
      
  		 if(checkDate()){
  		    $("#queryUserForm").attr("action","<%=basePath%>/profitShareDetail/queryProfitShareDetail.ct");
  			$("#queryUserForm").submit();
  		 }		
       });
       
       	$("#szPower").click(function() {
				
				var start=$("#minDate").val();
				if(start==""){ alert("请选择起始日期！");
				return;
				}
				var end =$("#maxDate").val();
			if(end=="") {
				alert("请选择截止日期！");
				return;
				}
				if( end.length>0 & start.length>0){
					$("#queryUserForm").attr("action","<%=basePath%>/profitShareDetail/excelProFitShareDetail.ct");
					$("#queryUserForm").submit();
				}	
	});
	
	});

function  checkDate(){
		var endTime = $("#maxDate").val();
		 var beginTime = $("#minDate").val();
		
		if(endTime=='' || beginTime==''){
			alert("起始时间范围必须选择!");
			return false;
		} 
		  var date1=str2date(beginTime);
		  var date2=str2date(endTime);
			if(date1.getMonth()!=date2.getMonth()){
			    alert("选择的起始时间不在同一个月内！");
				return false;
			}
		
		return true;
}	

  function str2date(str){   
    var d=null;   
    var reg=/^(\d{4})(\d{2})(\d{2})$/  ;
    if(arr=str.match(reg))d=new Date(Number(arr[1]),Number(arr[2])-1,Number(arr[3])) ; 
     return   d;   
  }  
  
  
  //选择代理商（ 传入值为table行数）
    function showPosInfoWindow(){
    
     var ScreenWidth = screen.availWidth ;
     var ScreenHeight = screen.availHeight; 
     var StartX = (ScreenWidth - innerWidth) / 2 ;
     var StartY = (ScreenHeight - innerHeight) / 2 ;
	 var url =  "<%=basePath%>query/queryAgentInit.ct";
	
	 window.open(url, '终端序列号信息', 'left='+ StartX + ', top='+ StartY + ', Width=' + innerWidth +', height=' + innerHeight + ', resizable=no, scrollbars=yes, status=no, toolbar=no, menubar=no, location=no'); 
	}
	
</script>
</head>
<body>
	<div class="subpage">
		<s:form id="queryUserForm" action="/profitShareDetail/queryProfitShareDetail.ct" method="post"
			theme="simple">
			<div class="user_title">
	    		 <h2 class="headline-inquires">POS收单运营管理平台<br />
	    		 <span class="sub-title">
	    		 </span></h2>
	    		</div>
			<table width="100%" cellpadding="0" cellspacing="0" border="0"
				class="query_table">
				<tr>
					<td colspan="4" align="center">
						<h2 class="headline-inquires">
							分润明细查询<br />
							<span class="sub-title"></span>
						</h2>
					</td>
				</tr>
				<tr>
					<td colspan="4">&nbsp;</td>
				</tr>

  
           
            <s:if test="#session.session_merchant.roleType==\"03\"||#session.session_merchant.roleType==\"15\" || #session.session_merchant.roleType==\"16\"">
				<td align="right" width="15%"></td>
				<td>
				  <s:hidden name="searchCondition.orgCode" value="%{#session.session_merchant.orgCode}" />
				</td>
			</s:if>
			<s:else>
			<tr>
			   <td align="right" width="15%">所属机构：</td>
				<td>		
					<s:select cssClass="queryWidth" name="searchCondition.orgCode"
						id="orgCode"
						list="#request.orgList" listKey="org_code" listValue="org_name"/>		
				</td>
			</tr>	
			</s:else>
				
						
				<tr>
					<td align="right">代理商账号：</td>
					<td align="left" colspan="1">
					
					<s:textfield id="accountNo" name="searchCondition.accountNo" cssClass="queryWidth" readonly="readonly" />
					<input type="button" value="选择" onclick="showPosInfoWindow()"/>
					</td>
							
					<td align="right">
							交易起始日期：
						</td>
						<td align="left" colspan="1">
							<s:textfield id="minDate" name="searchCondition.minDate"
								onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
								theme="simple" cssClass="queryWidth" />
							 至 
							<s:textfield id="maxDate" name="searchCondition.maxDate"
								onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
								theme="simple" cssClass="queryWidth" />
							<font color="red">*</font>
						</td>
				</tr>
			
				
				<tr>
						<td colspan="4" align="center"><span style="font-color: red"><s:actionerror /></span>
							<span style="font-color: red;"><s:actionmessage /></span > <span style="font-color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
					</tr>
				<tr>
					<td colspan="4" align="center">
					<input id="sub" value="查   询" type="button" />
					&nbsp;&nbsp;&nbsp;&nbsp;
					<s:if
								test="#request.searchRsList != null && #request.searchRsList.size>0">
								<input id="szPower" type="button" value="导出Excel" />&nbsp;&nbsp;&nbsp;&nbsp;
					   
					</s:if>
							<s:else>
								<input id="szPower" disabled="disabled" value="导出Excel"
									type="button" /> &nbsp;&nbsp;&nbsp;&nbsp;
					</s:else>
					</td>	
				</tr>
				
				<tr>
					<td colspan="4">&nbsp;</td>
				</tr>
			</table>
		</s:form>
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td colspan="4" align="center">
						<h2 class="headline-inquires">代理商分润列表</h2>
					</td>
				</tr>
				
				<s:if
					test="#request.searchRsList != null && #request.searchRsList.size>0">
					<tr>
						<td align="left">&nbsp;&nbsp;&nbsp;&nbsp; <page:pageCount
								max_pages="11" totalPage="${requestScope.totalPage}"
								currentPage="${requestScope.currentPage}"
								action="${rootPath}/profitShareDetail/queryProfitShareDetail.ct?currentPage=" />

						</td>
					</tr>
				</s:if>
				
			</table>
			<table id="tableList" width="100%" class="table">
				<thead>
					<tr>
						
						<th>商户名称</th>
						<th>商户号</th>
						<th>业务类型</th>
						<th>交易日期</th>
						<th>交易时间</th>
						<th>账号</th>
						<th>交易金额(元)</th>
						<th>分润金额(元)</th>
						<th>手续费(元)</th>
						<th>归属代理商</th>
						<th>上级代理商</th>
					</tr>
				</thead>
				<tbody>
					<s:iterator value="#request.searchRsList" status="stat" id="oper">
							<tr class="<s:if test="#stat.index%2==0">tr_0</s:if>" >
							
							<td>
							<s:property value="#oper.merName"/>
							</td>
							<td>
							<s:property value="#oper.mid"/>
							</td>
					        <td align="center"> 
					        <s:property value="#oper.mccTypeName"/>
							</td>
							<td>
							<s:property value="#oper.etsdate"/>
							</td>
							<td>
							<s:property value="#oper.etstime"/>
							</td>
							<td>
							<s:property value="#oper.account"/>
							</td>
							<td align="right"> 
					        <s:property value="#oper.amount"/>
							</td>
							<td align="right"> 
					        <s:property value="#oper.fenrunAmt"/>
							</td>
							<td align="right"> 
					        <s:property value="#oper.merfee"/>
							</td>
							<td>
							 <s:property value="#oper.realName"/>
							</td>
							<td>
							 <s:property value="#oper.realNameUp"/>
							</td>
							
						</s:iterator>
				</tbody>
			</table>
	</div>
</body>
</html>
